home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 17 / CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso / CUCD / Programming / DiceSource / lib / fd / mkdir.c < prev    next >
C/C++ Source or Header  |  1997-09-09  |  682b  |  38 lines

  1.  
  2. /*
  3.  *  MKDIR.C
  4.  *
  5.  *    (c)Copyright 1992-1997 Obvious Implementations Corp.  Redistribution and
  6.  *    use is allowed under the terms of the DICE-LICENSE FILE,
  7.  *    DICE-LICENSE.TXT.
  8.  */
  9.  
  10. #include <clib/dos_protos.h>
  11. #include <exec/types.h>
  12. #include <libraries/dos.h>
  13. #include <errno.h>
  14.  
  15. #ifndef UnixToAmigaPath
  16. #define UnixToAmigaPath(path)   path
  17. #endif
  18.  
  19. int
  20. mkdir(fileName)
  21. const char *fileName;
  22. {
  23.     BPTR lock;
  24.     int error;
  25.  
  26.     if (lock = CreateDir(UnixToAmigaPath(fileName))) {
  27.     UnLock(lock);
  28.     return(0);
  29.     }
  30.     error = IoErr();
  31.     if (error == ERROR_OBJECT_EXISTS || error == ERROR_DIRECTORY_NOT_EMPTY)
  32.     errno = EEXIST;
  33.     else
  34.     errno = ENOFILE;
  35.     return(-1);
  36. }
  37.  
  38.